package net.bac.sbe.web.sonar.client.widgets;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.google.gwt.user.client.ui.ListBox;

public class SbeListBox extends ListBox {

	public SbeListBox(boolean isMultipleSelect){
		super(isMultipleSelect);
	}

	public LinkedList<Integer> getSelectedIndexes() {
	    LinkedList<Integer> selectedItems = new LinkedList<Integer>();
	    for (int i = 0; i < getItemCount(); i++) {
	        if (isItemSelected(i)) {
	            selectedItems.add(i);
	        }
	    }
	    return selectedItems;
	}

	public List<String> getSelectedItems() {
	    List<String> selectedItems = new ArrayList<String>();
	    for (int i = 0; i < getItemCount(); i++) {
	        if (isItemSelected(i)) {
	        	selectedItems.add(getItemText(i));
	        }
	    }
	    return selectedItems;
	}
}
